<template>
    <div class="big">
        <!-- 导航栏 -->
        <div class="navigation">
            <span @click="back">
                <img src="../../assets/home-img/返回1.png" alt="">
            </span>
            <h3>预约挂号</h3>
            <span></span>
        </div>
        <!-- 身体 -->
        <div class="main">
            <div class="top">
                <img class="hospital" src="../../assets/home-img/医院.png" alt="">
                <h2 class="title">{{ reservationDetail.hospital }}</h2>
                <p class="label">
                    <span>公立</span>
                    <span>三级乙等</span>
                    <span>综合</span>
                </p>
                <div class="summarize">
                    <span>医院概括:</span>
                    <span style="color: #39a585;">查看简介 > </span>
                </div>
            </div>
            <div class="middle">
                <h4 class="distance">距您{{ reservationDetail.distance }}km</h4>
                <p class="address">{{ reservationDetail.address }}安外北苑路3号</p>
                <div class="btn">
                    <button>去挂号</button>
                </div>
            </div>
            <div class="bottom">
                <h3 class="our">本院医生</h3>
                <div class="reservationDetailItem" v-for="(item, index) in reservationDetail.doctors" :key="index">
                    <div class="our-l">
                        <img :src="item.avatar" alt="">
                    </div>
                    <div class="our-r">
                        <h3 class="name">{{ item.name }}&ensp;<span>{{ item.position }}</span> </h3>
                        <p class="department">
                            神经外科中心
                            <span>|</span>
                            {{ reservationDetail.hospital }}
                        </p>
                        <div class="excel">
                            <div class="van-multi-ellipsis--l2">
                                擅长:&ensp;{{ item.brief }}
                            </div>
                        </div>
                        <button class="register" @click="toExpertRegister(item.id)">去挂号</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import http from "../../http/http";

const route = useRoute();
const router = useRouter();
const reservationID = ref(route.query.id);
const reservationDetail = ref([]);

// 获取数据
const getReservationDetail = async () => {
    await http.get(`/registration?id=${reservationID.value}`).then(res => {
        reservationDetail.value = res.data.data;
    })
    localStorage.setItem("hospitalID", reservationID.value);
}

// 去挂号-医生
const toExpertRegister = (id) => {
    router.push({ path: "/expertRegister", query: { id: id } });
}

// 返回上一页
const back = () => {
    router.back();
};



onMounted(() => {
    getReservationDetail();
})
</script>

<style lang="scss" scoped>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.big {
    width: 100%;
    height: 100vh;
    background-color: #ecf8f6;
    overflow: scroll;
    -ms-overflow-style: none;

    &::-webkit-scrollbar {
        display: none;
    }

    .navigation {
        width: 100%;
        height: 92px;
        display: flex;
        background-color: #fff;
        justify-content: space-around;
        align-items: center;

        h3 {
            flex: 1;
            text-align: center;
            font-size: 35px;
        }

        span {
            width: 40px;
            padding-top: 7px;

            img {
                width: 40px;
                height: 40px;
                margin: 0 10px;
            }
        }
    }

    .main {
        width: 100%;
        height: 100%;
        background-color: #f6f6f6;
        padding: 0 20px;
        padding-top: 100px;

        .top {
            width: 100%;
            height: 250px;
            padding-top: 80px;
            background-color: #fff;
            border-radius: 10px;
            position: relative;

            .hospital {
                width: 120px;
                height: 120px;
                position: absolute;
                top: -60px;
                left: 30px;
            }

            .title {
                width: 100%;
                text-indent: 28px;
                line-height: 60px;
            }

            .label {
                width: 100%;
                padding-left: 20px;
                margin-top: 10px;

                span {
                    display: inline-block;
                    padding: 0 10px;
                    margin: 0 10px;
                    border: 2px solid #39a585;
                    border-radius: 8px;
                    color: #39a585;
                }
            }

            .summarize {
                width: 100%;
                height: 63px;
                display: flex;
                align-items: center;
                justify-content: space-between;
                padding: 0 20px;
            }
        }

        .middle {
            width: 100%;
            height: 230px;
            margin-top: 20px;
            border-radius: 10px;
            background-color: #fff;
            padding: 0 20px;
            padding-top: 20px;

            .distance {
                letter-spacing: 2px;
                line-height: 40px;
            }

            .address {
                color: #949494;
            }

            .btn {
                width: 100%;
                height: 110px;
                margin-top: 20px;
                display: flex;
                align-items: center;
                justify-content: center;

                button {
                    width: 100%;
                    height: 70px;
                    border-radius: 35px;
                    border: 0;
                    font-size: 30px;
                    color: #fff;
                    background-color: #00bd8d;
                }
            }
        }

        .bottom {
            width: 100%;
            height: 650px;
            margin-top: 20px;
            background-color: #fff;
            border-radius: 10px 10px 0 0;
            padding: 0 20px;

            .our {
                line-height: 80px;
            }

            .reservationDetailItem {
                width: 100%;
                margin-top: 10px;
                border-bottom: 1px solid #f0f0f0;
                display: flex;
                justify-content: space-between;

                .our-l {
                    width: 20%;
                    display: flex;
                    align-items: center;
                    justify-content: center;

                    img {
                        width: 80px;
                        height: 80px;
                        border-radius: 40px;
                    }
                }

                .our-r {
                    width: 80%;
                    position: relative;

                    .name {
                        line-height: 50px;
                        font-size: 30px;

                        span {
                            font-size: 25px;
                        }
                    }

                    .department {
                        color: #5f5f61;

                        span {
                            margin: 0 5px;
                        }
                    }

                    .excel {
                        color: #5f5f61;
                        margin-top: 8px;
                        margin-bottom: 20px;
                    }

                    .register {
                        position: absolute;
                        right: 0;
                        top: 0px;
                        padding: 12px 25px;
                        border-radius: 30px;
                        background-color: #00bd8d;
                        border: 0;
                        color: #fff;
                        font-size: 20px;
                    }
                }
            }
        }
    }
}
</style>
